﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcEngine.Core.Validation
{
    /// <summary>
    /// Stores the result of a failed validation
    /// </summary>
    public class BrokenRule
    {
        /// <summary>
        /// Gets or sets the name of the property .
        /// </summary>
        /// <value>The name of the property.</value>
        public string PropertyName { get; set; }

        /// <summary>
        /// Gets or sets the error message.
        /// </summary>
        /// <value>The error message.</value>
        public string ErrorMessage { get; set; }

        /// <summary>
        /// Gets or sets the id of the object that is validated. Contains null if such property is absent.
        /// </summary>
        /// <value>The id of the object that is validated.</value>
        public object Id { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BrokenRule"/> class.
        /// </summary>
        public BrokenRule()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BrokenRule"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="id">The id object that is validated.</param>
        public BrokenRule(string propertyName, string errorMessage, object id)
        {
            this.PropertyName = propertyName;
            this.ErrorMessage = errorMessage;
            this.Id = id;
        }

        public BrokenRule(string propertyName, string errorMessage)
        {
            this.PropertyName = propertyName;
            this.ErrorMessage = errorMessage;
        }
    }
}
